package com.googlecode.jot;

import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.Set;

/**
 * An abstract {@link TypeTranslator}.
 *
 * @param <Foreign> the foreign type
 * @param <Local> the local type
 */
public abstract class AbstractTypeTranslator<Foreign, Local>
	implements TypeTranslator<Foreign, Local> {

	private Set<Type> supportedLocalClasses
		= new HashSet<Type>();

	/**
	 * Adds a support local {@link Class} for translation.
	 * @param supportedLocal the local
	 */
	protected void addSupportedLocalClass(Type supportedLocal) {
		supportedLocalClasses.add(supportedLocal);
	}

	/**
	 * {@inheritDoc}
	 */
	public boolean supportsLocal(Type type) {
		return supportedLocalClasses.contains(type);
	}

}
